1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module soup.AuthDomain; 26 27 private import glib.Str; 28 private import glib.c.functions; 29 private import gobject.ObjectG; 30 private import soup.Message; 31 private import soup.c.functions; 32 public import soup.c.types; 33 34 35 /** */ 36 public class AuthDomain : ObjectG 37 { 38 /** the main Gtk struct */ 39 protected SoupAuthDomain* soupAuthDomain; 40 41 /** Get the main Gtk struct */ 42 public SoupAuthDomain* getAuthDomainStruct(bool transferOwnership = false) 43 { 44 if (transferOwnership) 45 ownedRef = false; 46 return soupAuthDomain; 47 } 48 49 /** the main Gtk struct as a void* */ 50 protected override void* getStruct() 51 { 52 return cast(void*)soupAuthDomain; 53 } 54 55 /** 56 * Sets our main struct and passes it to the parent class. 57 */ 58 public this (SoupAuthDomain* soupAuthDomain, bool ownedRef = false) 59 { 60 this.soupAuthDomain = soupAuthDomain; 61 super(cast(GObject*)soupAuthDomain, ownedRef); 62 } 63 64 65 /** */ 66 public static GType getType() 67 { 68 return soup_auth_domain_get_type(); 69 } 70 71 /** 72 * Checks if @msg contains appropriate authorization for @domain to 73 * accept it. Mirroring soup_auth_domain_covers(), this does not check 74 * whether or not @domain <emphasis>cares</emphasis> if @msg is 75 * authorized. 76 * 77 * This is used by #SoupServer internally and is probably of no use to 78 * anyone else. 79 * 80 * Params: 81 * msg = a #SoupMessage 82 * 83 * Returns: the username that @msg has authenticated 84 * as, if in fact it has authenticated. %NULL otherwise. 85 */ 86 public string accepts(Message msg) 87 { 88 auto retStr = soup_auth_domain_accepts(soupAuthDomain, (msg is null) ? null : msg.getMessageStruct()); 89 90 scope(exit) Str.freeString(retStr); 91 return Str.toString(retStr); 92 } 93 94 /** 95 * Adds @path to @domain, such that requests under @path on @domain's 96 * server will require authentication (unless overridden by 97 * soup_auth_domain_remove_path() or soup_auth_domain_set_filter()). 98 * 99 * You can also add paths by setting the %SOUP_AUTH_DOMAIN_ADD_PATH 100 * property, which can also be used to add one or more paths at 101 * construct time. 102 * 103 * Params: 104 * path = the path to add to @domain 105 */ 106 public void addPath(string path) 107 { 108 soup_auth_domain_add_path(soupAuthDomain, Str.toStringz(path)); 109 } 110 111 /** 112 * Adds a "WWW-Authenticate" or "Proxy-Authenticate" header to @msg, 113 * requesting that the client authenticate, and sets @msg's status 114 * accordingly. 115 * 116 * This is used by #SoupServer internally and is probably of no use to 117 * anyone else. 118 * 119 * Params: 120 * msg = a #SoupMessage 121 */ 122 public void challenge(Message msg) 123 { 124 soup_auth_domain_challenge(soupAuthDomain, (msg is null) ? null : msg.getMessageStruct()); 125 } 126 127 /** 128 * Checks if @msg authenticates to @domain via @username and 129 * @password. This would normally be called from a 130 * #SoupAuthDomainGenericAuthCallback. 131 * 132 * Params: 133 * msg = a #SoupMessage 134 * username = a username 135 * password = a password 136 * 137 * Returns: whether or not the message is authenticated 138 */ 139 public bool checkPassword(Message msg, string username, string password) 140 { 141 return soup_auth_domain_check_password(soupAuthDomain, (msg is null) ? null : msg.getMessageStruct(), Str.toStringz(username), Str.toStringz(password)) != 0; 142 } 143 144 /** 145 * Checks if @domain requires @msg to be authenticated (according to 146 * its paths and filter function). This does not actually look at 147 * whether @msg <emphasis>is</emphasis> authenticated, merely whether 148 * or not it needs to be. 149 * 150 * This is used by #SoupServer internally and is probably of no use to 151 * anyone else. 152 * 153 * Params: 154 * msg = a #SoupMessage 155 * 156 * Returns: %TRUE if @domain requires @msg to be authenticated 157 */ 158 public bool covers(Message msg) 159 { 160 return soup_auth_domain_covers(soupAuthDomain, (msg is null) ? null : msg.getMessageStruct()) != 0; 161 } 162 163 /** 164 * Gets the realm name associated with @domain 165 * 166 * Returns: @domain's realm 167 */ 168 public string getRealm() 169 { 170 return Str.toString(soup_auth_domain_get_realm(soupAuthDomain)); 171 } 172 173 /** 174 * Removes @path from @domain, such that requests under @path on 175 * @domain's server will NOT require authentication. 176 * 177 * This is not simply an undo-er for soup_auth_domain_add_path(); it 178 * can be used to "carve out" a subtree that does not require 179 * authentication inside a hierarchy that does. Note also that unlike 180 * with soup_auth_domain_add_path(), this cannot be overridden by 181 * adding a filter, as filters can only bypass authentication that 182 * would otherwise be required, not require it where it would 183 * otherwise be unnecessary. 184 * 185 * You can also remove paths by setting the 186 * %SOUP_AUTH_DOMAIN_REMOVE_PATH property, which can also be used to 187 * remove one or more paths at construct time. 188 * 189 * Params: 190 * path = the path to remove from @domain 191 */ 192 public void removePath(string path) 193 { 194 soup_auth_domain_remove_path(soupAuthDomain, Str.toStringz(path)); 195 } 196 197 /** 198 * Adds @filter as an authentication filter to @domain. The filter 199 * gets a chance to bypass authentication for certain requests that 200 * would otherwise require it. Eg, it might check the message's path 201 * in some way that is too complicated to do via the other methods, or 202 * it might check the message's method, and allow GETs but not PUTs. 203 * 204 * The filter function returns %TRUE if the request should still 205 * require authentication, or %FALSE if authentication is unnecessary 206 * for this request. 207 * 208 * To help prevent security holes, your filter should return %TRUE by 209 * default, and only return %FALSE under specifically-tested 210 * circumstances, rather than the other way around. Eg, in the example 211 * above, where you want to authenticate PUTs but not GETs, you should 212 * check if the method is GET and return %FALSE in that case, and then 213 * return %TRUE for all other methods (rather than returning %TRUE for 214 * PUT and %FALSE for all other methods). This way if it turned out 215 * (now or later) that some paths supported additional methods besides 216 * GET and PUT, those methods would default to being NOT allowed for 217 * unauthenticated users. 218 * 219 * You can also set the filter by setting the %SOUP_AUTH_DOMAIN_FILTER 220 * and %SOUP_AUTH_DOMAIN_FILTER_DATA properties, which can also be 221 * used to set the filter at construct time. 222 * 223 * Params: 224 * filter = the auth filter for @domain 225 * filterData = data to pass to @filter 226 * dnotify = destroy notifier to free @filter_data when @domain 227 * is destroyed 228 */ 229 public void setFilter(SoupAuthDomainFilter filter, void* filterData, GDestroyNotify dnotify) 230 { 231 soup_auth_domain_set_filter(soupAuthDomain, filter, filterData, dnotify); 232 } 233 234 /** 235 * Sets @auth_callback as an authentication-handling callback for 236 * @domain. Whenever a request comes in to @domain which cannot be 237 * authenticated via a domain-specific auth callback (eg, 238 * #SoupAuthDomainDigestAuthCallback), the generic auth callback 239 * will be invoked. See #SoupAuthDomainGenericAuthCallback for information 240 * on what the callback should do. 241 * 242 * Params: 243 * authCallback = the auth callback 244 * authData = data to pass to @auth_callback 245 * dnotify = destroy notifier to free @auth_data when @domain 246 * is destroyed 247 */ 248 public void setGenericAuthCallback(SoupAuthDomainGenericAuthCallback authCallback, void* authData, GDestroyNotify dnotify) 249 { 250 soup_auth_domain_set_generic_auth_callback(soupAuthDomain, authCallback, authData, dnotify); 251 } 252 253 /** */ 254 public bool tryGenericAuthCallback(Message msg, string username) 255 { 256 return soup_auth_domain_try_generic_auth_callback(soupAuthDomain, (msg is null) ? null : msg.getMessageStruct(), Str.toStringz(username)) != 0; 257 } 258 }